<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="common/include :: header('新增客户')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-customer-add" th:object="${customer}">
			<input type="hidden" name="id" th:field="*{id}">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="name" id="customerName" th:field="*{name}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户的联系方式：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="phone" id="customerCode" th:field="*{phone}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户的年龄：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="age" id="customerSort" th:field="*{age}" required>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="common/include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "/system/customer";
	    
		/*$("#form-customer-add").validate({
			onkeyup: false,
			rules:{
				name:{
					remote: {
		                url: prefix + "/checkCustomerNameUnique",
		                type: "customer",
		                dataType: "json",
		                data: {
		                	"name" : function() {
		                        return $.common.trim($("#customerName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				code:{
					remote: {
		                url: prefix + "/checkCustomerCodeUnique",
		                type: "customer",
		                dataType: "json",
		                data: {
		                	"code" : function() {
		                        return $.common.trim($("#customerCode").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				customerSort:{
					digits:true
				},
			},
			messages: {
		        "code": {
		            remote: "客户编码已经存在"
		        },
		        "name": {
		            remote: "客户名称已经存在"
		        }
		    },
		    focusCleanup: true
		});*/
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-customer-add').serialize());
	        }
	    }
	</script>
</body>
</html>
